package com.example.finalframe.config;
import com.example.finalframe.interceptor.CheckRoleInterceptor;
import com.example.finalframe.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    @Autowired
    LoginInterceptor loginInterceptor;
    @Autowired
    CheckRoleInterceptor checkRoleInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPatterns("/**")都拦截，除了这些("/static/**","/login","/index");
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/static/**","/api/login","/index","/file/upload");
        registry.addInterceptor(checkRoleInterceptor).addPathPatterns("/api/roles");
        }
}